home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.6 KB | 102 lines | [TEXT/GEOL] |
- Item 2361268 21-Oct-88 17:07
-
- From: CREMER.M Cremer, Mike
-
- To: D1430 HewLett Packard, Dev, Steve Henry
-
- cc: MACAPP.TECH$ MACAPP Tech
- MACDTS Macintosh Developer Technical Supt.
-
- Sub: re Default Button Woes
-
- Hal,
- You don't mention whether you are using modal or modeless dialogs--there is a
- difference in the way to handle each. Modal dialogs could be done something
- like this:
- { codefrag for modal dialog in MacApp 2.0 }
- VAR
- aWindow : TWindow;
- dismisser : IDType;
- BEGIN
- aWindow := NewTemplateWindow(vMyDialog, NIL);
- { set default information, if any }
- dismisser := TDialogView(aWindow.FindSubView('DLOG')).PoseModally;
- IF (dismisser = 'ok ') THEN
- { get information from fields/buttons }
- aWindow.Close;
- END;
-
- where { get information } could be checking the status of controls (i.e. radio
- buttons/check boxes) or reading text from EditText fields. This could also be
- handled by overriding TDialogView.DismissDialog.
-
- A resource setup for above codefrag could be something like:
-
- /* rez code for standard ok/cancel modal dialog, MacApp 2.0 */
- resource 'view' (vMyDialog) {
- {
- root, 'WIND', { 50, 50 }, { 200, 300 },
- sizeFixed, sizeFixed, shown, enabled,
- Window {
- "TWindow",
- dBoxProc, noGoAwayBox, notResizable, modal,
- ignoreFirstClick, freeOnClosing, disposeOnFree,
- closesDocument, openWithDocument, dontAdaptToScreen,
- dontStagger, forceOnScreen, centerHorizontally,
- 'DLOG', /* !!! window target view is set to DLOG part of view
- */
- "OK/Cancel Dialog"
- };
-
- /* The actual DialogView object */
- 'WIND', 'DLOG', { 0, 0 }, { 200, 300 },
- sizeFixed, sizeFixed, shown, enabled,
- DialogView {
- "TDialogView", /* or whatever */
- 'ok ', /* specifies the OK and CANCEL default controls */
- 'cncl' /* used by MacApp for Return and Command-. respectively
- */
- };
-
- 'DLOG', 'ok ', { 160, 110 }, { 28, 80 },
- sizeFixed, sizeFixed, shown, enabled,
- Button {
- "TButton",
- adnRRect, {3, 3}, /* hilite the default control */
- notSizeable, notDimmed, notHilited,
- dismisses, /* says this control should call DismissDialog */
- { 4, 4, 4, 4 }, systemFont,
- "OK"
- };
-
- 'DLOG', 'cncl', { 164, 30 }, { 20, 80 },
- sizeFixed, sizeFixed, shown, enabled,
- Button {
- "TButton",
- noAdornment, notSizeable, notDimmed, notHilited,
- dismisses, noInset, systemFont,
- "Cancel"
- };
-
- /* Plus whatever items are in the dialog itself.
- Which could include other controls, handled
- in the TDialogView.DoChoice method */
-
- Modal dialogs are a bit trickier. A quick-n-dirty way is to override
- TDialogView.HandleCR so that it hilites the default button and calls your
- method (look at the code to see how MacApp does it).
-
- The key factor here is to make sure the TWindow resource definition targets
- TDialogView by default, which alleviates all the tedious mucking about in
- fields. Above, when the window is opened, it automagically targets 'DLOG'
- which gets the first shot at handling the event. The DialogView resource
- should specify the equivalent of "OK" and "Cancel" default items.
-
- Hope this helps.
-
- $mike cremer
- Apple Computer, Inc.
-
-
-
-